import pytest
import json
import os

# 获取项目路径
BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def read_data_from_json(file_path):
    data = {}
    with open(file_path, 'r', encoding="utf-8") as fp:
        data = json.load(fp)
    print(f"返回的参数：{data}")
    return data


@pytest.mark.parametrize("param", read_data_from_json(BASE_PATH + "\\pytest15_parametrize参数化数据来自json文件\\data.json"))
def test_case(param):
    print(f"uname={param['uname']}, pwd={param['pwd']}")